package br.com.ngame.demos;

import java.awt.event.KeyEvent;
import ngamejava2.BaseGame;
import ngamejava2.InputManager;

public class MyGame extends BaseGame
{
	@Override
	public void load()
	{
	}

	@Override
	public void unload()
	{
	}

	@Override
	public void update(long currentTick)
	{
		if (getMainPlaneManager() != null)
		{
			if (InputManager.getInstance().isPressed(KeyEvent.VK_HOME))
			{
				getMainPlaneManager().getCamera().height += 5;
			}
			if (InputManager.getInstance().isPressed(KeyEvent.VK_END))
			{
				getMainPlaneManager().getCamera().height -= 5;
			}
			if (InputManager.getInstance().isPressed(KeyEvent.VK_F12))
			{
				setFullScreen(!isFullScreen());
			}
			if (InputManager.getInstance().isPressed(KeyEvent.VK_ESCAPE))
			{
				terminate();
			}
			getMainPlaneManager().getViewport().x = 0;
			getMainPlaneManager().getViewport().y = 0;
			getMainPlaneManager().getViewport().width = getWidth();
			getMainPlaneManager().getViewport().height = getHeight();
			float aspectRatio = (float) getWidth() / getHeight();
			getMainPlaneManager().getCamera().width = getMainPlaneManager().getCamera().height * aspectRatio;
//		getMainPlaneManager().centerCameraAt(actor);
			getMainPlaneManager().update(currentTick);
		}
	}
}
